//
//  SelectActivityNumViewController.m
//  AndCampus
//
//  Created by 史宵宵 on 2018/1/31.
//  Copyright © 2018年 史宵宵. All rights reserved.
//

#import "SelectActivityNumViewController.h"
#import "EnterActivityInforViewController.h"

@interface SelectActivityNumViewController ()<UIGestureRecognizerDelegate>

@end

@implementation SelectActivityNumViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.titleLabel.text = self.activityInfo.title;
    self.moneyLabel.text = [NSString stringWithFormat:@"合计  ¥%.1f",[self.activityInfo.fee floatValue] ];
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disSeleteMood:)];
    tap.delegate=self;
    [self.view addGestureRecognizer:tap];
    self.view.userInteractionEnabled = YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if (touch.view==self.view) {
        return YES;
    }
    else
        return NO;
}
- (void)disSeleteMood:(UITapGestureRecognizer *)tap{
    [self dismissViewControllerAnimated:YES completion:^{

    }];

}
- (IBAction)minusNum:(id)sender {
    if ([self.numLabel.text intValue]>1) {
        self.numLabel.text = [NSString stringWithFormat:@"%d",[self.numLabel.text intValue]-1];
        self.moneyLabel.text = [NSString stringWithFormat:@"合计  ¥%.1f",[self.activityInfo.fee floatValue] * [self.numLabel.text intValue] ];
    }
}
- (IBAction)addNum:(id)sender {
    self.numLabel.text = [NSString stringWithFormat:@"%d",[self.numLabel.text intValue]+1];
    self.moneyLabel.text = [NSString stringWithFormat:@"合计  ¥%.1f",[self.activityInfo.fee floatValue] * [self.numLabel.text intValue] ];
}

- (IBAction)disViewController:(id)sender {
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
- (IBAction)nextStep:(id)sender {
//    __weak typeof(self) unself = self;
    [self dismissViewControllerAnimated:NO completion:^{
        
    }];
    EnterActivityInforViewController *enterActivityInforVC = [[EnterActivityInforViewController alloc]init];
    enterActivityInforVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    enterActivityInforVC.moneyStr = [NSString stringWithFormat:@"%.1f",[self.activityInfo.fee floatValue] * [self.numLabel.text intValue] ];
    enterActivityInforVC.numStr = self.numLabel.text;
    enterActivityInforVC.activityInfo = self.activityInfo;
    UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
    [appRootVC presentViewController:enterActivityInforVC animated:YES completion:^{
        
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
